﻿using MQTTnet.Protocol;
using MQTTnet.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleMqttTemplate
{
	internal class CustomConnectionValidator : IMqttServerConnectionValidator
	{
		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <returns></returns>
		public async Task ValidateConnectionAsync(MqttConnectionValidatorContext context)
		{
			if (context.Username == "username" && context.Password == "password")
			{
				context.ReasonCode = MqttConnectReasonCode.Success;
				return;
			}
			context.ReasonCode = MqttConnectReasonCode.BadAuthenticationMethod;
		}
	
	}
}
